<style>
.fui-list-inner .vip {
	background: #09ba07 none repeat scroll 0 0;
    color: #fff;
    position: absolute;
    margin-left: 0.2rem;
    height: 0.75rem;
    width: 0.75rem;
    vertical-align: top;
    z-index: 100;
    line-height: 1.1;
    text-align: center;
    border-radius: 0.85rem;
}
.item-up-content {background-color: #fff;border-radius: 10px;padding:0.5rem;}
.weui_cells {padding:0;margin-top:0}
.weui_cell_bd {padding:0;padding-bottom:0.3rem;padding-top:0.3rem;color:#999;font-size:0.7rem}
.weui_cell_hd {font-size:0.7rem;padding-bottom:0.3rem;padding-top:0.3rem;margin-right:0.3rem}
.item-ng {}
.item-ng .deleteitem {position: absolute;color:#000;margin-top:-1rem;right:0.5rem}
.weui_cells_title{font-weight: bold;margin:0.5rem;padding-left:0.2rem;padding-right:0}
.weui_input {
  background-color: #fff;
}
.pic {position:relative;font-size:0.6rem;}
.setimg {position:absolute;top:0.5rem;right:0.5rem;padding:0 0.5rem;color:#fff;background-color:rgba(0,0,0,0.5);border-radius:1rem;}
.fui-navbar, .fui-footer {
    width: auto;
	padding:0.3rem 0.5rem;
}
.fui-navbar .nav-item.btn {
    border-radius: 1rem;
	height:1.8rem;
}
</style>
<div class="fui-page fui-page-current" ng-if="pagedata.op=='main'">
	<div class="fui-content">
		<div class="content-block" style="padding:0.5rem">
			<div ng-if="!pagedata.post.logo" class="fui-cellone bold">
				 <div class="fui-cellone-label" style="width:auto">
					活动封面设置
				 </div>
				 <div class="fui-cellone-info">
				 </div>
				 <div class="fui-cellone-remark" ng-click="pagedata.op='tukus'">
					添加封面
				 </div>
			</div>
			<div ng-if="pagedata.post.logo" class="pic">
				<div class="setimg" ng-click="pagedata.op='tukus'" ><i class="icon icon-tuwen"></i> 更换封面</div>
				<img class="radiustop" ng-src="{{tomedia(pagedata.post.logo) || '../core/resource/images/nopic.jpg'}}" style="display: block; width: 100%; height: 6rem;">
			</div>
			<div class="item-up-content" style="border-top-left-radius:0;border-top-right-radius:0">
			<div style="">
				<input class="weui_input" type="text" ng-model="pagedata.post.title" placeholder="请输入活动标题（最多50字）">
			</div>
			<div ng-if="pagedata.groups.length>0" class="fui-cellone" style="padding:0;padding-top:0.3rem">
                <div class="fui-cellone-label" style="width:auto;padding-right:0.3rem">活动类型</div>
				<div class="fui-cellone-text">
					<select class="weui_select" style="padding:0.3rem" name="groupid" ng-model="pagedata.post.groupid">
                        <option ng-repeat="item in pagedata.groups" value="{{item.id}}">{{item.title}}</option>
					</select>
				 </div>
            </div>
			</div>
			<div ng-include="sys_html('gamehtml/_diycontent')"></div>
			<div ng-if="pagedata.post.gamename=='jy_merchtool_red'" ng-include="sys_html('gamehtml/_tool_red')"></div>
			<div ng-if="pagedata.post.gamename=='jy_merchtool_fee'" ng-include="sys_html('gamehtml/_tool_fee')"></div>
			<div ng-if="pagedata.post.gamename=='jy_merchtool_gq'" ng-include="sys_html('gamehtml/_tool_gq')"></div>
			<div ng-if="pagedata.isdiygoods==1" ng-include="sys_html('gamehtml/_diygoods')"></div>
			<div ng-if="pagedata.isdiyform==1" ng-include="sys_html('gamehtml/_diyform')"></div>
			<div ng-include="sys_html('gamehtml/_gameset')"></div>
			<div ng-include="sys_html('gamehtml/_otherset')"></div>
			<div class="weui_cells_checkbox" style="margin-top:1.2rem">
					<div class="fui-cell-label" style="text-align:center;margin:0 auto;padding:0.2rem;font-size:0.56rem">
						<input type="checkbox" class="fui fui-checkbox fui-checkbox-danger verify-checkbox" ng-checked="pagedata.post.checked==true" ng-model="pagedata.post.checked">
						我已阅读并同意 <a ng-click="pagedata.show_xieyi=true" style="color:#61bba7">《会员协议》</a>
					</div>
			</div>
		</div>
	</div>
	<div class="fui-navbar">
		<div ng-if="pagedata.type!=2 && (pagedata.isid!=1 || pagedata.post.noshow==1)" style="width:30%;float:left"><a ng-click="pagedata.submit(1);" class="nav-item btn btn-success" style="color:#fff;border-right: 1px solid #fff;">保存预览</a></div>
		<div ng-if="pagedata.type!=2 && (pagedata.isid!=1 || pagedata.post.noshow==1)" style="width:70%;float:left"><a href="javascript:;" ng-click="pagedata.submit(0);" class="nav-item btn btn-success" style="color:#fff">发布活动</a></div>
		<div ng-if="pagedata.type!=2 && pagedata.isid==1 && pagedata.post.noshow!=1" style="width:100%;float:left"><a href="javascript:;" ng-click="pagedata.submit(0);" class="nav-item btn btn-success" style="color:#fff">发布活动</a></div>
		<div ng-if="pagedata.type==2" ><a href="javascript:;" ng-click="pagedata.payred();" class="nav-item" style="color:#fff">发布活动</a></div>
	</div>
</div>
<div ng-include="sys_html('gamehtml/_canyufileds')"></div>
<div ng-include="sys_html('common/_xieyi')"></div>
<div ng-include="sys_html('tukus')"></div>
<div ng-include="sys_html('gamehtml/_editgoods')"></div>
<script>
scope.pagedata.post.checked =true
scope.pagedata.selecttext=1
if(scope.pagedata._RQ.snsid =='0'){
	window.scope.location(function(re){
		scope.pagedata.post.pcd={};
		scope.pagedata.post.pcd.province = re.addressComponents.province
		scope.pagedata.post.pcd.city = re.addressComponents.city
		scope.pagedata.post.pcd.district = re.addressComponents.district
		scope.$evalAsync();
	});
}
scope.pagedata.pushgoods=function(){
	scope.pagedata.post.fileds.push(angular.copy(scope.pagedata.newfileds))
}
scope.pagedata.submit=function(e,id){
	if(!scope.pagedata.post.checked){
		scope.message('请先阅读并勾选《发帖规则》','error');
		return false;
	}
	if(!scope.pagedata.post.title){
		scope.message('标题不能为空！','error');
		return false;
	}
	if(!scope.pagedata.post.content){
		scope.message('内容不能为空！','error');
		return false;
	}
	if(votestrlen(scope.pagedata.post.title)>120){
		scope.message('标题不能超过60个字！','error');
		return false;
	}
	scope.pagedata.post.noshow = e==1?1:0;
	if(id){
		scope.pagedata.post.payid =id
	}
	var params={
		data:scope.pagedata.post,
		op:'post',
		callback:function(res){
		}
	};
	scope.post_json(params);
}
scope.pagedata.payred=function(){
	if(!scope.pagedata.post.title){
		scope.message('标题不能为空！','error');
		return false;
	}
	if(!scope.pagedata.post.content){
		scope.message('内容不能为空！','error');
		return false;
	}
	if(votestrlen(scope.pagedata.post.title)>40){
		scope.message('标题不能超过20个字！','error');
		return false;
	}
	scope.post_json('payred',scope.pagedata.post,function(pay_id){
		require(['tool'],function(tool){
			tool.pay(pay_id,function(res){
				console.log('收到支付结果！');
				if(res.type=='success'){
					scope.pagedata.submit(0,pay_id);
				}else{
					scope.message('充值失败！');
				}
			});
		});
	});
}
function votestrlen(str){
    var len = 0;
    for (var i=0; i<str.length; i++) { 
     var c = str.charCodeAt(i); 
    //单字节加1 
     if ((c >= 0x0001 && c <= 0x007e) || (0xff60<=c && c<=0xff9f)) { 
       len++; 
     } 
     else { 
      len+=2; 
     } 
    } 
    return len;
}
</script>
<script>
scope.pagedata.up_file=function(index){
	scope.choose_source(scope.pagedata.post.content[index],['data','thumb'],'video');
}
</script>